<!DOCTYPE html>
<html>
<head>
	<title>while</title>
	<meta charset="utf-8" />
</head>
<body>

</body>
</html>
<script type="text/javascript">
	//while 循环的应用尝试
	//1.同步双循环
	function for1(){//内部i
		for(let i=0;i<5;i++){
			console.log(i)
		}
	}
	let ic=1;
	function for2(){//外部ic
		for(ic=0;ic<5;ic++){
			console.log('ic',ic)
		}
		ic=null;
	}
	let arr=[1,1,1,1,1];
	//while是否能跟随for一起循环
	while(for1()){//没有返回值，不执行
		console.log("whilefor1")
	}
	while(ic){
		console.log('whilefor2')//只执行一遍
		for2();
	}
	//无限循环
	// while(arr.map(v=>v)){
		// console.log("whilemap")
	//}

	//2.正则匹配中的应用
	var regex = /t(e)(st(\d?))/g;
	var string = 'test1test2test3';

	var matches = [];
	var match;
	while (match = regex.exec(string)) {//exec运行一次改变一次指针
	  matches.push(match);
	}
	console.log(matches)
	
</script>